Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Attributes of Geometric Objects

Every QuickDraw 3D geometric object can contain one or more optional sets of attributes, which define characteristics of all or part of the object, such as its color or other material properties. For example, QuickDraw 3D defines the data associated with a triangle like this:

typedef struct TQ3TriangleData {
    TQ3Vertex3D                         vertices[3];
    TQ3AttributeSet                     triangleAttributeSet;
} TQ3TriangleData;

As you can see, the triangle data consists of three vertices that define the triangle's position, together with a set of attributes that specify characteristics of the planar area enclosed by the lines connecting those vertices. A set of attributes is simply a collection of attributes, each of which consists of an attribute type and its associated data. Some common attribute types are diffuse color, specular color, surface normal vector, transparency, and so forth. You can, if you wish, define your own custom types of attributes and include them in attribute sets like any other kind of attribute. See the chapter "Attribute Objects" for complete information on the types of attributes defined by QuickDraw 3D and on defining custom attribute types.

You can associate a set of attributes with most parts of a geometric object. For example, you can associate a set of attributes with the face of a triangle or with one or more of the triangle's vertices. Similarly, a box can have an attribute set for the entire box as well as an attributes set for each of the six faces of the box. In this way, you can assign different colors to each of the box faces. Accordingly, QuickDraw 3D defines the data associated with a box like this:

typedef struct TQ3BoxData {
    TQ3Point3D                          origin;
    TQ3Vector3D                         orientation;
    TQ3Vector3D                         majorAxis;
    TQ3Vector3D                         minorAxis;
    TQ3AttributeSet                     *faceAttributeSet;
    TQ3AttributeSet                     boxAttributeSet;
} TQ3BoxData;

The boxAttributeSet field is a set of attributes that apply to the entire box, and the faceAttributeSet field is a pointer to an array of attribute sets that apply to the six faces of the box.

Trimeshes do not use attribute sets. See "Trimeshes" for information on specifying attributes for a trimesh and its parts.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |